﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
public partial class SystemManage_GroupList : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    private int pageIndex
    {
        get
        {
            if (Request.Params["page"] == null)
                return 1;
            else
            {
                return int.Parse(Request.Params["page"]);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("100300");
        if (!IsPostBack)
        {
            Bind();
        }
    }
    private void Bind()
    {
        int pageCount, Counts;
        List<Model.USERGROUP> l = new BLL.USERGROUP().GetList(20, pageIndex, "UG_CODE", false, " AND UG_CODE!='000' ", out pageCount, out Counts);
        USERGROUPListControl1.Bind(l);
        PageControl1.Bind(pageIndex, 20, Counts, Request.Url.ToString(), "page");
    }
    public void Add()
    {
        if (Check.CheckPermission("100300", "00001"))
        {
            Response.Redirect("GroupEdit.aspx");
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
    public void Update()
    {
        if (Check.CheckPermission("100300", "00002"))
        {
            List<string> s = USERGROUPListControl1.Selected;
            if (s.Count > 0)
            {
                Response.Redirect("GroupEdit.aspx?ugcode=" + s[0]);
            }
            else
            {
                Share.Alert(this.Page, "请选择一条需要编辑的记录"); 
            }
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
    public void Delete()
    {
        if (Check.CheckPermission("100300", "00003"))
        {
            List<string> s = USERGROUPListControl1.Selected;
            new BLL.USERGROUP().Delete(s);
            Share.InsertLog("100300", "00003");
            Response.Redirect("GroupList.aspx");
        }
        else
        {
            Share.Alert(this.Page,"无权操作"); return;
        }
    }
}
